package com.pruebas.andEngine;

import org.anddev.andengine.engine.handler.physics.PhysicsHandler;
import org.anddev.andengine.entity.sprite.AnimatedSprite;
import org.anddev.andengine.opengl.texture.region.TiledTextureRegion;

public class Androidzito extends AnimatedSprite{
	private final PhysicsHandler mPhysicsHandler;
	private Float posicionActual = (float) 0;
	private Boolean ida = true;
	
	public Androidzito(final float pX, final float pY, final TiledTextureRegion pTextureRegion){
		super(pX, pY, pTextureRegion);
		this.mPhysicsHandler = new PhysicsHandler(this);
	    this.registerUpdateHandler(this.mPhysicsHandler);
	}

	public void setVelocityY(float velocity){
	    mPhysicsHandler.setVelocityY(velocity);
	}
	
	public boolean moveSprite(){
		posicionActual = this.getX();
		
		if(ida){
			if(this.getX() < 240){
				this.setPosition(posicionActual + 20, this.getY());
				return true;
			}
			else if(this.getX() == 240){
				ida = false;
				//
				return true;
			}
			
		}
		else{
			if(posicionActual > 160){
				this.setPosition(posicionActual - 20, this.getY());
				return true;
			}
			else{
				ida = true;
				return false;
			}
		}
		return false;
	}
		
	
	
}
